namespace ASPNETMVC4Tutorial.Migrations
{
    using System;
    using System.Data.Entity.Migrations;
    
    public partial class Add_Table_Student_Score : DbMigration
    {
        public override void Up()
        {
            CreateTable(
                "dbo.Students",
                c => new
                    {
                        ID = c.Int(nullable: false, identity: true),
                        Name = c.String(nullable: false),
                    })
                .PrimaryKey(t => t.ID);
            
            CreateTable(
                "dbo.Scores",
                c => new
                    {
                        ID = c.Int(nullable: false, identity: true),
                        StudentId = c.Int(nullable: false),
                        Course = c.Int(nullable: false),
                        ScoreValue = c.Int(nullable: false),
                    })
                .PrimaryKey(t => t.ID)
                .ForeignKey("dbo.Students", t => t.StudentId, cascadeDelete: true)
                .Index(t => t.StudentId);
            
            DropTable("dbo.People");
        }
        
        public override void Down()
        {
            CreateTable(
                "dbo.People",
                c => new
                    {
                        ID = c.Int(nullable: false, identity: true),
                        FirstName = c.String(nullable: false),
                        LastName = c.String(nullable: false),
                    })
                .PrimaryKey(t => t.ID);
            
            DropIndex("dbo.Scores", new[] { "StudentId" });
            DropForeignKey("dbo.Scores", "StudentId", "dbo.Students");
            DropTable("dbo.Scores");
            DropTable("dbo.Students");
        }
    }
}
